package com.ruoyi.mapper;

import com.ruoyi.domain.AdvInoutstock;
import com.ruoyi.domain.AdvMembers;
import com.ruoyi.domain.Heart;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * Mapper接口
 *
 * @author ruoyi
 * @date 2024-05-13
 */
public interface AdvMembersMapper {
    /**
     * 查询
     *
     * @param advMembersId 主键
     * @return
     */
    public AdvMembers selectAdvMembersByAdvMembersId(Long advMembersId);

    /**
     * 查询列表
     *
     * @param advMembers
     * @return 集合
     */
    public List<AdvMembers> selectAdvMembersList(AdvMembers advMembers);

    /**
     * 查询列表(新，关联上级会员表))
     *
     * @param advMembers
     * @return 集合
     */
    public List<AdvMembers> selectAdvMembersListForp(AdvMembers advMembers);

    // 根据id查询下级会员
    public List<AdvMembers> selectSecondMembers(@Param("advMemberId") Long memberId);

    /**
     * 新增
     *
     * @param advMembers
     * @return 结果
     */
    public int insertAdvMembers(AdvMembers advMembers);

    /**
     * 修改
     *
     * @param advMembers
     * @return 结果
     */
    public int updateAdvMembers(AdvMembers advMembers);

    /**
     * 删除
     *
     * @param advMembersId 主键
     * @return 结果
     */
    public int deleteAdvMembersByAdvMembersId(Long advMembersId);

    /**
     * 批量删除
     *
     * @param advMembersIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteAdvMembersByAdvMembersIds(Long[] advMembersIds);

    /**
     * 根据id判断是否有下级会员
     */
    public Integer checkNextById(@Param("advMembersId") Long advMembersId);

    /**
     * 根据id获得下级会员id
     */
    @Select("select adv_members_id from adv_members where parent_account = #{advMembersId}")
    public List<Long> getNextIds(@Param("advMembersId") Long advMembersId);

//    /**
//     * 根据设备编号查询会员ID
//     * @param devicesno
//     * @return
//     */
//    Long getMemberId(@Param("devicesno") String devicesno);

    /**
     * 根据该设备编号id查询直播信息
     * @param devicesno
     * @return
     */
    List<Map<String, Object>> getBroadcasts(@Param("devicesno") String devicesno);

    //查询所有主播
    List<AdvMembers> selectAnchor();

    //删除会员邮寄地址管理表
    void deleteMemberByAddr(Long[] advMembersIds);

    //删除留言反馈表
    void deleteMemberByMsg(Long[] advMembersIds);

    //删除会员点赞表
    void deleteMemberByInfoliks(Long[] advMembersIds);

    //删除会员直播表
    void deleteMemberByReservbroadcast(Long[] advMembersIds);

    //会员收藏表
    void deleteMemberByCollect(Long[] advMembersIds);

    //删除订单明细表
    void deleteMemberByOrdersdetail(Long[] advMembersIds);

    //删除会员结算收益明细表
    void deleteMemberByIncomedetail(Long[] advMembersIds);

    //删除会员结算收益表
    void deleteMemberByIncome(Long[] advMembersIds);

    //删除订单主表
    void deleteMemberByOrders(Long[] advMembersIds);

    @Update("update adv_members set pay_rate = #{payRate} where pay_rate = #{lastRateValue} or pay_rate is null")
    int resetRate(AdvMembers advMembers);

    AdvMembers selectByWeOpenID(@Param("weOpenid") String weOpenid);
}
